# Contributor: Celeste <cielesti@protonmail.com>
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=nmail
pkgver=4.54
pkgrel=0
pkgdesc="Terminal-based email client"
url="https://github.com/d99kris/nmail"
arch="all"
license="MIT"
depends="cyrus-sasl-login"
makedepends="
	cmake
	cyrus-sasl-dev
	file-dev
	libetpan-dev
	linux-headers
	ncurses-dev
	openssl-dev
	samurai
	sqlite-dev
	util-linux-dev
	xapian-core-dev
	"
subpackages="$pkgname-doc $pkgname-oauth::noarch"
source="https://github.com/d99kris/nmail/archive/v$pkgver/nmail-$pkgver.tar.gz"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_SHARED_LIBS=ON \
		-DCMAKE_BUILD_TYPE=None \
		-DHAS_CUSTOM_LIBETPAN=OFF
	cmake --build build
}

check() {
	./build/nmail --version

	ctest --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	install -Dvm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/
}

oauth() {
	pkgdesc="$pkgdesc (OAuth2 Python helper script)"
	depends="$pkgname=$pkgver-r$pkgrel py3-requests"

	amove usr/bin/oauth2nmail
}

sha512sums="
e8c221bfa4891d1133ad98d273c75b522644c7e21f36d869b33e933205aad959e44012406fffdc028fefef07632c9609bacd56d3486de371b6a04bb69c1d1bc1  nmail-4.54.tar.gz
"
